package com.kotlin.android.simple.progressdialog

import androidx.activity.viewModels
import androidx.lifecycle.Observer
import com.kotlin.android.core.BaseVMActivity
import com.kotlin.android.mtime.ktx.ext.progressdialog.dismissProgressDialog
import com.kotlin.android.mtime.ktx.ext.progressdialog.showProgressDialog
import com.kotlin.android.simple.R

/**
 * 加载对话框示例代码：
 *
 * Created on 2020/6/12.
 *
 * @author o.s
 */
class ProgressDialogActivity : BaseVMActivity<ProgressDialogViewModel>(false) {
    override fun getLayoutResId(): Int = R.layout.simple_main

    override fun initVM(): ProgressDialogViewModel = viewModels<ProgressDialogViewModel>().value

    override fun initView() {
    }

    override fun initData() {
    }

    override fun startObserve() {
        mViewModel?.run {
            uiState.observe(this@ProgressDialogActivity, Observer {
                if (it.showLoading) {
                    showProgressDialog()
                } else {
                    dismissProgressDialog()
                }
            })
        }
    }
}